#!/usr/bin/env python
# -*- coding: utf-8 -*-
# --------------------------------------------------
#Author:    LJ
#Email:     admin@attacker.club

#Date:      18-4-3
#Description: dns change
# --------------------------------------------------
import os

#shell
def shell(cmd):
    os.system(cmd)

print(
    """
    1.阿里dns
    2.公司dns
    3.线上dns
    4.外网dns
    """)
dns=int(input("输入要切换的数字:"))


if __name__ == "__main__":
    if dns == 1:
        shell('echo "nameserver 223.5.5.5" > /etc/resolv.conf')
    elif dns == 2:
        shell('echo "nameserver 10.0.99.1" > /etc/resolv.conf')
    elif dns == 3:
        shell('echo "nameserver 192.168.14.2" > /etc/resolv.conf')
    else:
        shell('echo "nameserver 8.8.8.8" > /etc/resolv.conf')

    with open('/etc/resolv.conf') as f:
        text = f.read().split()
        f.close()
        print("\n%s\033[31m %s\033[0m" % (text[0], text[1]))



